<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
[#include "/admin/include/head.htm"]
<script type="text/javascript">
	var memberGrid;
	var siteNoticeGrid;
	$(function(){
		 memberGrid = $("#maingrid1").ligerGrid({
            columns: [
			{name: 'id', hide: true, width:0, isAllowHide: false},
			{display: '会员帐号', name: 'username', align: 'center', width: 100 },
            {display: '电子邮箱', name: 'email', align: 'center', width: 150 },
            {display: '手机号码', name: 'mobile', align: 'center', width: 100 }
			],
            pageSize:20, url: base + '/admin/b2c/member/queryData.jhtml',
			toolbar: false, width: '100%', height:'100%', enabledSort: true
        });
        $("#pageloading").hide();
		//绑定搜索按钮
		LG.search(memberGrid);
		
		siteNoticeGrid = $("#maingrid").ligerGrid({
            columns: [
			{hide: true, name: 'id'},
		    {display: '会员名称', name: 'member.username', align: 'left', minWidth: 120},
		    {display: '是否阅读', name: 'isRead', dict: 'common',align: 'left', minWidth: 120},
		    {display: '删除', name: 'isDelete', dict: 'common', align: 'left', minWidth: 120},
			],  pageSize:20, url: base + '/admin/b2c/siteNotice/queryData.jhtml?textId=${textId}',
			toolbar: {items:[{ text: '删除', click: f_delete, icon: 'remove'}]}, width: '100%', height:'100%', enabledSort: true
        });
        $("#pageloading").hide();
		//绑定搜索按钮
		search(siteNoticeGrid);
		
        $("#pageloading").hide();
        
		$("#search_btn_reset2").css("display", "none");
		
		$("div.l-icon.l-icon-remove").html('<img src="${base}/resource/images/icons/silkicons/delete.png" width="15px" height="15px">');
	});
	
	//关联
	function correlate(){
		var selecteds = memberGrid.getSelecteds();
	    if (selecteds.length > 0) {
	    	jQuery.ligerDialog.confirm('确定关联吗', function (confirm) {
      			if (confirm){
					LG.ajax({
						url: base + '/admin/b2c/siteNotice/correlate.jhtml',
			            data: { textId:'${textId}', memberIds: LG.getIds(selecteds) },
			            success: function () {
							LG.showSuccess('关联成功');
			                f_reload('maingrid');
			            },
			            error: function (message) {
							LG.showError(message);
			            }
			        });
			    }
			});
		} else {
			LG.tip('请在会员列表选择关联接收者!');
	    }
	}
	
	//删除
	function f_delete(){
		var selecteds = siteNoticeGrid.getSelecteds();
	    if (selecteds.length > 0) {
	    	jQuery.ligerDialog.confirm('确定删除吗？', function (confirm) {
      			if (confirm){
					LG.ajax({
						url: base + '/admin/b2c/siteNotice/delete.jhtml',
			            loading: '正在删除中...',
			            data: { ids: LG.getIds(selecteds) },
			            success: function () {
							LG.showSuccess('删除成功');
			                f_reload();
			            },
			            error: function (message) {
							LG.showError(message);
			            }
			        });
			    }
			});
		} else {
			LG.tip('请在已关联列表选择行!');
	    }
	}
	
	function search(grid, p){
		p = $.extend({
			beforeSearch: null, //搜索之前调用的函数
			afterSearch: null //搜索之后调用的函数
		}, p || {});
		$("#functions input").keydown(function(e){
			if(e.keyCode==13){
				$("#search2").click();
			}
		});
		$("#search2").click(function(){
			var self = this;
			this.p = p;
			if ($.isFunction(self.p.beforeSearch)) {
				self.p.beforeSearch();
			}
			var searchData = getWarpPara("functions2");
			delete searchData[""];
			var flag = false;
			for (var key in searchData) {
				if (searchData[key].trim() != "") {
					flag = true;
					break;
				}
			}
			if (flag) {
				$("#search_btn_reset2").css("display", "inline");
				grid.options.parms = searchData;
				grid.options.newPage=1; //将搜索页变成第一页
				grid.loadData(true);
				if ($.isFunction(self.p.afterSearch)) {
					self.p.afterSearch();
				}
			}
		});
		
		$("#search_btn_reset2").click(function(){
			clearSearchWeiget("functions2");
			grid.options.parms = null;
			grid.loadData(true);
			$(this).css("display", "none");
		});
	};
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div>
		<div style="margin:0; padding:0; float: left;width:45%;">
			<div id="functions">
				<div class="clearfix">
					<div style="float:left;">
						<span>
							登录帐号:<input type="text" class="formText" style="width: 60px" name="search_LIKE_username"/>
						</span>
						<span>
							电子邮箱:<input type="text" class="formText" style="width: 60px" name="search_EQ_email"/>
						</span>
						<span>
							手机号码:<input type="text" class="formText" style="width: 60px" name="search_EQ_mobile"/>
						</span>
						<br/>
						<input type="button" class="button" value="搜索" id="search"/>
						<a href="#" id="search_btn_reset" face="Wingdings 3">清除本次搜索</a>
					</div>
				</div>
			</div>
			<div id="maingrid1" style="margin:0; padding:0; "></div>
		</div>
		
		<div style="padding:200px 10px 0px 10px; float:left;width: 5%">
			<input style="width:60px;height: 30px;background: #F4D08A" type="button" onclick="correlate()" value="关联>>" />
		</div>
		
		<div style="margin:0; padding:0;float: right;width:45%;">
			<div id="functions2">
				<div class="clearfix">
					<div style="float:left;">
						<span>
							会员名称：<input type="text" class="formText" name="search_EQ_member.username"/>
						</sapn>
						<span>
							是否阅读：[@u.select headerKey="" headerValue="全部" list={"true":"是","false":"否"} name="search_EQ_isRead" /]
						</sapn>
						<span>
							是否删除：[@u.select headerKey="" headerValue="全部" list={"true":"是","false":"否"} name="search_EQ_isDelete" /]
						</sapn>
						<input type="button" class="button" value="搜索" id="search2"/>
						<a href="#" id="search_btn_reset2" face="Wingdings 3">清除本次搜索</a>
					</div>
				</div>
			</div>
			<div id="maingrid" style="margin:0; padding:0;"></div>
		</div>
	</div>
	
</body>
</html>